package com.ysh.gsm;

import java.io.Serializable;



import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 * @author ysh
 *
 */
@Entity
@Table(name = "call_table")
@NamedQueries( {
	@NamedQuery(name = "calls.findAll", query = "from Call"),
	@NamedQuery(name = "calls.byId", query = "select c from Call c where c.callKey= :callKey"),
	@NamedQuery(name = "calls.time", query = "select c from Call c LEFT JOIN c.timeDimension td"),
	@NamedQuery(name = "calls.timeKey", query = "select c from Call c where c.timeDimension= :timeDimension"),
	@NamedQuery(name = "calls.callType", query = "select c from Call c where c.callType= :callType"),
	@NamedQuery(name = "calls.BDUR", query = "select c from Call c where c.callDuration> :callDuration"),
	@NamedQuery(name = "calls.SDUR", query = "select c from Call c where c.callDuration< :callDuration"),
	
})

public class Call implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8951759845936344586L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "call_key")
	private Long callKey;
	@Column(name = "global_call_id")
	private int globalCallId;
	@Column(name = "call_type")
	private byte callType;
	
	@Column(name = "start_time")
	private int startTime;
	
	@Column(name = "start_time_ext")
	private short startTimeExt;
	

	
	@Column(name = "end_time")
	private int endTime;
	@Column(name = "end_time_ext")
	private short endTimeExt;
	
	@Column(name = "call_duration")
	private long callDuration;
	@Column(name = "flags")
	private byte flags;
	@Column(name = "failure_code")
	private long failureCode;
	@Column(name = "failure_reason")
	private String failureReason;
	@Column(name = "handover_num")
	private byte handOverNum;
	@Column(name = "called_number")
	private long calledNumber;
	@Column(name = "calling_imsi")
	private long callingIMSI;
	@Column(name = "calling_tmsi")
	private int callingTMSI;
	
	@Column(name = "called_imsi")
	private long calledIMSI;
	@Column(name = "called_tmsi")
	private int calledTMSI;
	@Column(name = "calling_number")
	private long callingNumber;
	
//	@Column(name = "rx_qual_worst")
//	private byte rxQualWorst;
//	@Column(name = "rx_qual_avg")
//	private byte rxQualAvg;
	@Column(name = "tag_mask")
	private long tagMask;
	@JoinColumn(name = "time_key", referencedColumnName = "time_key")
	@ManyToOne(optional = false)
	private TimeDimension timeDimension;
	
	public Call(){
		
		super();
	}
	
	public Call (long cd,byte ct,long cn,long cim,int tim,int et,short etx,
			byte rx,long fc,String fr,byte fl,int gl,byte ha,byte rqw,int st,short stx,long tag,TimeDimension td){
		
		this.callDuration=cd;
		this.callType=ct;
		this.calledNumber=cn;
		this.callingIMSI=cim;
		this.callingTMSI=tim;
		this.endTime=et;
		this.endTimeExt=etx;
		//this.rxQualAvg=rx;
		this.failureCode=fc;
		this.failureReason=fr;
		this.flags=fl;
		this.globalCallId=gl;
		this.handOverNum=ha;
		//this.rxQualWorst=rqw;
		this.startTime=st;
		this.startTimeExt=stx;
		this.tagMask=tag;
		this.timeDimension=td;
		
	}
	
	public long getCalledIMSI() {
		return calledIMSI;
	}

	public void setCalledIMSI(long calledIMSI) {
		this.calledIMSI = calledIMSI;
	}

	public int getCalledTMSI() {
		return calledTMSI;
	}

	public void setCalledTMSI(int calledTMSI) {
		this.calledTMSI = calledTMSI;
	}

	public long getCallingNumber() {
		return callingNumber;
	}

	public void setCallingNumber(long callingNumber) {
		this.callingNumber = callingNumber;
	}

	public Long getCallKey() {
		return callKey;
	}
	public void setCallKey(Long callKey) {
		this.callKey = callKey;
	}
	public int getGlobalCallId() {
		return globalCallId;
	}
	public void setGlobalCallId(int globalCallId) {
		this.globalCallId = globalCallId;
	}
	public byte getCallType() {
		return callType;
	}
	public void setCallType(byte callType) {
		this.callType = callType;
	}
	public int getStartTime() {
		return startTime;
	}
	public void setStartTime(int startTime) {
		this.startTime = startTime;
	}
	public short getStartTimeExt() {
		return startTimeExt;
	}
	public void setStartTimeExt(short startTimeExt) {
		this.startTimeExt = startTimeExt;
	}
	public int getEndTime() {
		return endTime;
	}
	public void setEndTime(int endTime) {
		this.endTime = endTime;
	}
	public short getEndTimeExt() {
		return endTimeExt;
	}
	public void setEndTimeExt(short endTimeExt) {
		this.endTimeExt = endTimeExt;
	}
	public long getCallDuration() {
		return callDuration;
	}
	public void setCallDuration(long callDuration) {
		this.callDuration = callDuration;
	}
	public byte getFlags() {
		return flags;
	}
	public void setFlags(byte flags) {
		this.flags = flags;
	}
	public long getFailureCode() {
		return failureCode;
	}
	public void setFailureCode(long failureCode) {
		this.failureCode = failureCode;
	}
	public String getFailureReason() {
		return failureReason;
	}
	public void setFailureReason(String failureReason) {
		this.failureReason = failureReason;
	}
	public byte getHandOverNum() {
		return handOverNum;
	}
	public void setHandOverNum(byte handOverNum) {
		this.handOverNum = handOverNum;
	}
	public long getCalledNumber() {
		return calledNumber;
	}
	public void setCalledNumber(long calledNumber) {
		this.calledNumber = calledNumber;
	}
	public long getCallingIMSI() {
		return callingIMSI;
	}
	public void setCallingIMSI(long callingIMSI) {
		this.callingIMSI = callingIMSI;
	}
	public long getCallingTMSI() {
		return callingTMSI;
	}
	public void setCallingTMSI(int callingTMSI) {
		this.callingTMSI = callingTMSI;
	}
//	public byte getRxQualWorst() {
//		return rxQualWorst;
//	}
//	public void setRxQualWorst(byte rxQualWorst) {
//		this.rxQualWorst = rxQualWorst;
//	}
//	public byte getRxQualAvg() {
//		return rxQualAvg;
//	}
//	public void setRxQualAvg(byte rxQualAvg) {
//		this.rxQualAvg = rxQualAvg;
//	}
	public long getTagMask() {
		return tagMask;
	}
	public void setTagMask(long tagMask) {
		this.tagMask = tagMask;
	}
	public TimeDimension getTimeDimension() {
		return timeDimension;
	}
	public void setTimeDimension(TimeDimension timeDimension) {
		this.timeDimension = timeDimension;
	}
	

}
